﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Web.Model
{
    public class TreeItem
    {

        public TreeItem(string id = "", string pid = "",string title="", int level=3, string url = "",IEnumerable<TreeItem> children = null,string menuitemId = "")
        {
            this.Id = id;
            this.Pid = pid;
            this.Title = title;
            this.Level = level;
            this.Data_Url = url;
            this.MenuItemId = menuitemId;
            this.Children = children;
            this.Name = id;
        }
        public string Id { get; set; }
        public string Title { get; set; }
        public string Pid { get; set; }

        public string Name { get; set; }
        public int Level { get; set; }
        public string MenuItemId { get; set; }

        private string _data_url;
        public string Data_Url
        {
            set
            {
                if (Level == 3)
                {
                    _data_url = value;
                }
            }
            get
            {
                return _data_url;
            }
        }
        public string Data_Faicon
        {
            get
            {
                if (Level == 1)
                {
                    return " data-faicon='star-o' ";
                }
                else if (Level==2)
                {
                     return " data-faicon='folder-open-o' ";
                }
                else if(Level == 3)
                {
                    return " data-faicon='caret-right' ";
                }
                return string.Empty;
            }
        }
        public string Data_Faicon_Close
        {
            get
            {
                if (Level==2)
                {
                    return " data-faicon-close='folder-o' ";
                }
                return string.Empty;
            }
        }
        
        public string Data_Tit
        {
            get
            {
                if (Level == 1)
                {
                    return " data-tit = '" + Title + "' ";
                }
                return string.Empty;
            }
        }

        public string Data_TabId
        {
            get { return " data-tabid='" + this.Name + "' "; }
        }

        public IEnumerable<TreeItem> Children { get; set; }
    }
}